<!DOCTYPE HTML>
<html>
    <head>
        <title>Aufgabe 1</title>
    </head>
    <body>
        <?php
            class ShoppingCartMySQL extends PDO {
                
                protected $db;
                
                /**Opens the Database. Requires databasename, username and password**/
                public function __construct(){
                    $dsn = 'mysql:host=localhost;dbname=swa20;port=4433';
                    try {
                        $this->db = new PDO( 
                        $dsn, 
                        'root', 
                        'phpuser'); 
                        /*** echo a message saying we have connected ***/
                        echo 'Connected to database <br>';
                        
                    }
                    catch(PDOException $e) {
                        echo $e->getMessage();
                    }
                }
				
                /** Closes the database connection **/
                function __destruct(){
                    $this->db = null;
                }
             
            }

        ?>
    </body>

</html>